//
//  ZYRequest.h
//  JW_BasePorject
//
//  Created by JW on 2018/6/13.
//  Copyright © 2018年 JW. All rights reserved.
//

#import "ZYBaseRequest.h"


FOUNDATION_EXPORT NSString *const ZYRequestCacheErrorDomain;

NS_ENUM(NSInteger) {
    ZYRequestCacheErrorExpired = -1,
    ZYRequestCacheErrorVersionMismatch = -2,
    ZYRequestCacheErrorSensitiveDataMismatch = -3,
    ZYRequestCacheErrorAppVersionMismatch = -4,
    ZYRequestCacheErrorInvalidCacheTime = -5,
    ZYRequestCacheErrorInvalidMetadata = -6,
    ZYRequestCacheErrorInvalidCacheData = -7,
    };

@interface ZYRequest : ZYBaseRequest

@property (nonatomic) BOOL ignoreCache;

- (BOOL)isDataFromCache;

- (BOOL)loadCacheWithError:(NSError * __autoreleasing *)error;

- (void)startWithoutCache;

- (void)saveResponseDataToCacheFile:(NSData *)data;

#pragma mark - Subclass Override

- (NSInteger)cacheTimeInSeconds;

- (long long)cacheVersion;

- (nullable id)cacheSensitiveData;


- (BOOL)writeCacheAsynchronously;

@end
